function sendUrl(url) 
{
  if(url=='')
  {
        return;
  }
  
  conect=postRequest();
  conect.onreadystatechange = procesarEventos;
  //conexion1.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  conect.open("GET", url, true);
  conect.send(null);
}

function postRequest() 
{
  var xmlHttp=null;
  if (window.XMLHttpRequest) {
	  xmlHttp = new XMLHttpRequest();
  }
  else if (window.ActiveXObject) {
	      xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  }
  return xmlHttp;
}

function procesarEventos()
{
	
  if(conect.readyState == 4)
  {
	  accepted(conect.responseText);
  } 
}   
        function accepted(str){
            if(str=="yes"){
        	alert('Registro Finalizado');
        	document.location.href='index.php';
        	}else{
				alert('Se ha presentado algun problema. Intentar mas tarde');
            }
        }
       
        function saveUser(){
        	
        	 var password = document.getElementById('password').value;
        	 var password2 = document.getElementById('password2').value;
        	 resp=confirm("Registrarte?");
        	 if(password==password2){
	    		if(resp) 
	    		{  
    		        var name = document.getElementById('name').value;
    		        var last_name = document.getElementById('last_name').value;
    		        var email = document.getElementById('email').value;
    		        var password = document.getElementById('password').value;
    		        var url = "save_user.php?name="+name+"&last_name="+last_name+"&email="+email+"&password="+password ;
    		        sendUrl(url);
	    		}
	    		else
	    			return false;
        	 }
        	 else{
        		 alert("verifique el password este no coincide");
        	 }
        }